package cn.hp.kyc;

import cn.hp.kyc.money.User;
import java.util.*;

/**
 * @author yc
 * @year 2022年05月24日20:42
 */
public class AdminUser {
    public void adminUser(boolean sign,List<User> list) {
        Scanner sc = new Scanner(System.in);
        while (sign) {
            System.out.println("*****************************************");
            System.out.println("********1.查看用户        2.修改用户*******");
            System.out.println("********3.删除             4.查看工资******");
            System.out.println("********5.退卡                   *********");
            System.out.println("*****************************************");
            int operate1 = sc.nextInt();
            if (operate1 == 1) {
                    System.out.print("   账号    |");
                    System.out.print("   姓名  |");
                    System.out.print("  密码  |");
                    System.out.print("  电话  |");
                    System.out.print("  余额  ");
                    System.out.println();




                for (int i = 0; i < list.size(); i++) {
                    System.out.print(list.get(i).getAccount()+"|");
                    System.out.print(list.get(i).getName()+"|");
                    System.out.print(list.get(i).getPassword()+"|");
                    System.out.print(list.get(i).getPhone()+"|");
                    System.out.print(list.get(i).getBalance());
                    System.out.println();
                }
            }
            if (operate1 == 2) {
                int aa=0;
                boolean sign1 = true;
                while (sign1){
                    System.out.println("请输入要修改的用户账号：");
                    String account1 = sc.nextLine();
                    for (int i = 0; i < list.size(); i++) {
                        if (account1.equals(list.get(i).getAccount())){
                            aa=i;
                            sign1=false;
                        }
                    }
                }
                System.out.println("姓名：[如果不修改此属性直接按回车键]");
                String account2 = sc.nextLine();
                if (account2!=null||account2.equals("")){
                        User stu = list.get(aa);
                        stu.setName(account2);
                }
                System.out.println("密码：[如果不修改此属性直接按回车键]");
                String account3 = sc.nextLine();
                if (account3!=null||account3.equals("")){
                    User stu = list.get(aa);
                    stu.setName(account3);
                }
                System.out.println("手机号：[如果不修改此属性直接按回车键]");
                String account4 = sc.nextLine();
                if (account4!=null||account4.equals("")){
                    User stu = list.get(aa);
                    stu.setName(account4);
                }
            }
            if (operate1 == 3) {
                int aa=0;
                boolean sign1 = true;
                while (sign1){
                    System.out.println("请输入要删除的用户账号：");
                    String account1 = sc.nextLine();
                    for (int i = 0; i < list.size(); i++) {
                        if (account1.equals(list.get(i).getAccount())){
                            aa=i;
                            sign1=false;
                        }
                    }
                }
                list.remove(aa);
            }
            if (operate1 == 4) {
                    System.out.println("10001");
            }
            if (operate1 == 5) {
                System.out.println("是否确认要退出");
                System.out.println("请输入Y/N");
                String aa = sc.next();
                if (aa.equalsIgnoreCase("y")) {
                    sign = false;
                }
            }
        }
    }
}